package com.zhu.day.controller;

import com.google.common.base.Charsets;
import com.google.common.io.Files;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class LuckyService {

    public static void main(String[] args) {
        String nowName = "luckyList.txt";
        LuckyService ck = new LuckyService();
        List<String> list = ck.readFile(nowName);
        System.out.println("==="+list.size());
        /*List<List<String>> partition = Lists.partition(list, 200);
        for (List<String> strings : partition) {
            System.out.println(JsonUtils.toJSON(strings));
        }*/
    }

    private List<String> readFile(String nowName) {
        String filePath = LuckyService.class.getClassLoader().getResource(nowName).getPath();
        try {
            List<String> list1 = new ArrayList<>();
            List<String> list = Files.readLines(new File(filePath), Charsets.UTF_8);
            list.stream().forEach(line -> {
                String[] s = line.split("\t");
                String starid = s[0];
                list1.add(starid.trim());
            });
            int size = list1.size();
            System.out.println("readFile.count:"+size);
            return list1;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }
}
